import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common';
import { AddressService } from './address.service';
import { User } from 'src/module/system/user/user.decorator';
import { CreateAddressDto, UpdateAddressDto } from './dto/address.dto';

@Controller('shop/address')
export class AddressController {
  constructor(private readonly addressService: AddressService) {}

  @Get()
  findList(@User() user: Record<string, any>) {
    return this.addressService.findList(user.id);
  }

  @Post()
  create(@User() user: Record<string, any>, @Body() address: CreateAddressDto) {
    return this.addressService.create(user.id, address);
  }

  @Put()
  update(@User() user: Record<string, any>, @Body() address: UpdateAddressDto) {
    return this.addressService.update(user.id, address);
  }

  @Delete(':id')
  remove(@Param() id: number, @User() user: Record<string, any>) {
    return this.addressService.remove(id, user.id);
  }
}
